<?php
	/* Template Name: Reference Category Page */ 
?>

<?php get_header() ?>

	<div id="container">
    
    	<?php include('breadcrumbs.php'); ?>
    
    	<?php get_sidebar() ?>
    
		<div id="content">

<?php the_post() ?>

			<div id="post-<?php the_ID() ?>" class="<?php sandbox_post_class() ?>">
				<h2 class="entry-title"><?php the_title() ?></h2>
                <?php include ('socialbuttons.php'); ?>
				<div class="entry-content">
<?php the_content() ?>

				</div>
                
                <?php
$args = array(
'orderby' => 'menu_order', // Allows users to set order of subpages
'order' => 'ASC',
'numberposts' => '-1',
'post_parent' => $post->ID,
'post_type' => 'page',
'post_status' => 'publish'
); $postslist = get_posts($args);
foreach ($postslist as $post) : setup_postdata($post); ?>

						<div class="category-item">
                        	<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                        	<div class="product-thumb" style="float: left; margin-right: 10px; margin-bottom: 10px;">
								
                                <a href="<?php the_permalink(); ?>">
        						<?php if(has_post_thumbnail()) { echo the_post_thumbnail();
									} elseif (get_post_meta($post->ID, "MainImg", true)) { include('pr-thumb-image-2.php') ;
									} else {
										include('pr-thumb-image.php') ;
									}
								?>
        						</a>
                                
                            </div>
                            <?php the_excerpt(); ?>
                            <p><a href="<?php the_permalink(); ?>">View More</a></p>
                            <div style="width: 660px; height: 1px; background-color: #cccccc; clear: both; margin-top: 10px; margin-bottom: 10px;"></div>
						</div>

					<? endforeach; ?>
                
			</div><!-- .post -->
            
            <!-- INCLUDE END OF PAGE CTA BLOCK IF THE PAGE HAS A CTA URL -->
            <?php if(get_post_meta($post->ID, "ctaURL", true)){ include('inpagecta.php') ; } ?>

		</div><!-- #content -->
	</div><!-- #container -->

<?php get_footer() ?>